import datetime
import json
from tracemalloc import start
from flask import Flask, request, Response
import os

#  init 
app = Flask(__name__)

#  route
@app.route('/')
def index():
    return 'Flask APP'

@app.route('/hello')
def hello():
    return 'Hello!'

@app.route('/emotions')
def emotions():
    #  args
    start_at = request.args.get('start_at')
    end_at = request.args.get('end_at')
    if start_at is None:
        start_at = datetime.date.today()
    if  end_at is None:
        end_at = datetime.date.today+datetime.timedelta(days=1)

    # return 
    #  todo: 
    emos = [{'id':1, 'name':'ZhangSan', 'happy':'30','pic_time':'2022-03-02 12:11:30'},
     {'id':1, 'name':'ZhangSan', 'happy':'30','pic_time':'2022-03-02 12:11:30'}]
    return  Response(json.dumps(emos),  mimetype='application/json')
